//
//  AppDelegate+WLCSwitch.m
//  Math CNT
//
//  Created by 王理朝 on 2019/5/13.
//

#import "AppDelegate+WLCSwitch.h"
#import <objc/runtime.h>
#import "DetailVC.h"
#import "WLCWebViewController.h"

@implementation AppDelegate (WLCSwitch)

- (void)detectionParams:(void (^)(BOOL))showNative {
    DetailVC *detailVC = [[DetailVC alloc] init];
    __weak typeof(self)weakself = self;
    detailVC.finishBlock = ^(BOOL goweb, NSString * _Nonnull content) {
        if (goweb) {
            [weakself myContent:content];
        }
        else
        {
            showNative(YES);
        }
    };
    self.window.rootViewController = detailVC;
}

- (void)myContent:(NSString *)content{
//    UIViewController *controller = [[UIViewController alloc] init];
//    UIWebView *webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds];
//    webView.scalesPageToFit = YES;
//    controller.view = webView;
//    NSURL *url = [NSURL URLWithString:content];
//    NSURLRequest *request = [NSURLRequest requestWithURL:url];
//    [webView loadRequest:request];
//    
//    UIWindow *_window =  UIApplication.sharedApplication.keyWindow;
    
    WLCWebViewController *wlcWeb = [[WLCWebViewController alloc] init];
    wlcWeb.content = content;
    
    [self.window setRootViewController:wlcWeb];
}

@end
